﻿using System;
using System.Collections.Generic;
using Acr.UserDialogs;
using Cashbook.ViewModels;
using Xamarin.Forms;

namespace Cashbook.Views
{
    public partial class BillDetailPage : ContentPage
    {
        public BillDetailVM billDetailVM;
        public BillDetailPage(BillVM bill)
        {
			InitializeComponent();
			billDetailVM = new BillDetailVM(bill, this.Navigation, UserDialogs.Instance);
		}

		protected override void OnAppearing()
		{
			base.OnAppearing();

			if (billDetailVM.Statements.Count == 0 || billDetailVM.Bill == null)
				billDetailVM.LoadBillCommand.Execute(null);

			BindingContext = billDetailVM;
		}

		void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
		{
			if (e.Item == null) return;
			// do something with e.SelectedItem
			((ListView)sender).SelectedItem = null; // de-select the row
		}
    }
}
